﻿using UnityEngine;
using System.Collections;
using System.Text;

namespace CHFramework
{
    public class SysDefine
    {
        public const string TagCanvas = "TagCanvas";

        public const string NormalUIRoot = "NormalUIRoot";
        public const string ExceptNormalUIRoot = "ExceptNormalUIRoot";
        public const string FixedUIRoot = "FixedUIRoot";
        public const string PopupUIRoot = "PopupUIRoot";
        public const string LoadingUIRoot = "LoadingUIRoot";
        public const string ScriptUIRoot = "ScriptRoot";

        public const string UIRootPath = "UIRoot";

        public const string UIPanelPath = "UIPrefabs/";

        #region 事件ID
        public const int UpdateCoin = 1;             //刷新金币数据
        public const int UpdateCash = 2;             //刷新钻石数据
        #endregion

        #region AssetBundle
        public static string AssetPathOnPlatform
        {
            get
            {
#if UNITY_EDITOR
                return Application.dataPath + "/StreamingAssets/";
#elif UNITY_IPHONE
                return Application.dataPath + "/Raw/";
#elif UNITY_ANDROID
                return "jar:file://" + Application.dataPath + "!/assets/";
#endif
            }
        }
        #endregion

        public static Language CurLanguage = Language.Chinese;
    }

    #region 界面定义
    /// <summary>
    /// 窗体类型
    /// </summary>
    public enum EnumPanel
    {
        None,
        UILoadingPanel,
        UILoginPanel,
        UICreatePanel,
        UIMainPanel,
        UITopMainPanel,
        UIShopPanel,
        UIInGamePanel,
        UISettingPanel,
        UIPausePanel,
    }

    /// <summary>
    /// UI窗体类型（位置）
    /// </summary>
    public enum UIPanelType
    {
        //正常
        Normal,
        //二级及以上界面
        ExceptNormal,
        //固定
        Fixed,
        //弹出
        Popup,
        //loading
        Loading,
    }

    /// <summary>
    /// UI窗体显示类型
    /// </summary>
    public enum UIPanelShowMode
    {
        //普通
        Normal,
        //反向切换
        ReverseChange,
        //隐藏其他
        HideOther,
    }

    /// <summary>
    /// UI窗体透明度类型
    /// </summary>
    public enum UIPanelLucencyType
    {
        //完全透明，不能穿透
        Lucency,
        //半透明，不能穿透
        Translucence,
        //低透明度，不能穿透
        ImPanetrable,
        //可以穿透
        Pentate,
    }

    public class UIType
    {
        //是否清空“栈集合”
        public bool IsClearStack = false;
        public UIPanelType PanelType = UIPanelType.Normal;
        public UIPanelShowMode ShowMode = UIPanelShowMode.Normal;
        public UIPanelLucencyType LucencyType = UIPanelLucencyType.Lucency;
    }
    #endregion

    #region 文件路径工具类

    public class FileUtils
    {
        private static string DATA_ROOT_PATH = string.Format("{0}/", Application.streamingAssetsPath);

        /// <summary>
        /// 构造函数
        /// </summary>
        private FileUtils() { }

        /// <summary>
        /// 获取真实路径
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static string GetPath(string file)
        {
            return DATA_ROOT_PATH + file;
        }

        /// <summary>
        /// 获取本地路径
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static string GetLocalPath(string file)
        {
            return file;
        }
    }
    #endregion

    #region xml文件操作
    public class XmlHelper
    {
        private StringBuilder builder;

        public XmlHelper()
        {
            builder = new StringBuilder();
        }

        public void AddStart(string node)
        {
            builder.AppendFormat("<{0}>", node);
        }

        public void AddEnd(string node)
        {
            builder.AppendFormat("</{0}>", node);
        }

        public void CreateElement(string node, string value)
        {
            builder.AppendFormat("<{0}>{1}</{0}>", node, value);
        }

        public override string ToString()
        {
            return builder.ToString();
        }
    }
    #endregion

    #region 多国语言

    public enum Language
    {
        None = 0,
        Chinese,
        English,
    }

    #endregion
}
